/*
* ECARX Technology Limited is the owner of the copyright and the trade secret of this software.
* Without permission, no one has the right to obtain, disclose or use this software in any way.
*/

package ecarx.xsf.notificationcenter.sdk;

import java.util.ArrayList;
import java.util.List;

/**
 * FileName: DataTransformUtil.java <br>
 * Description : 数据转换工具类<br>
 * Create Time: 2021/9/2 16:04 <br>
 * Update Time: 2021/9/2 16:04 <br>
 *
 * @since 1.0.0
 */
public class DataTransformUtil {


    public static IStatusBarNotification transform(AbstractBaseNotification notification) {
        return new IStatusBarNotification(notification.getId(), notification.getPackageName(), notification.getStyle(), notification.getTitle(),
                notification.getContent(), notification.getIcon(), notification.getContentIntent(), notification.getDeleteIntent(),
                notification.isTyrant(), notification.isTtsOn(), notification.seeSay(), notification.isBeep(), notification.getUrl(),
                getAction(notification.getActions()), getAction(notification.getSeeSayEventActions()), getAction(notification.getSmartCardActions()), notification.getSubStyle(),
                notification.getTag(), notification.getWhen());
    }

    private static List<IStatusBarAction> getAction(List<AbstractStatusBarAction> actions) {
        List<IStatusBarAction> actionList = new ArrayList<>();
        if (actions != null) {
            for (AbstractStatusBarAction action : actions) {
                if (action != null) {
                    actionList.add(new IStatusBarAction(action.getId(), action.getText(), action.getBgUrl(), action.getFunctionId(), action.getPendingIntent()));
                }
            }
        }
        return actionList;
    }
}
